# RMORPG Build File
# SCons must be installed on your system to build RMORPG.
# To build simply type:
# % scons
# or less verbose:
# % scons -Q
# To clean up the build type:
# % scons -c

##### ENVIRONMENT #####

### Compiler (GNU C++)
env = Environment(CXX='g++')

##### Header files #####
env.Append(CPPPATH = '#include')

##### LIBRARIES #####

##### CONFIGURATION #####
conf = Configure(env)

if not conf.CheckCXXHeader('ctime'):
	print "C++ header 'ctime.h' not found."
	Exit(1)
if not conf.CheckCXXHeader('iostream'):
	print "C++ header 'iostream.h' not found."
	Exit(1)
if not conf.CheckCXXHeader('fstream'):
	print "C++ header 'fstream.h' not found!"
	Exit(1)

env = conf.Finish()

## OPTIONAL

# Check Compile Mode
mode = ARGUMENTS.get('mode', 'release')
if not (mode in ['debug', 'release']):
	print "Error: expected 'debug' or 'release', found: " + mode
	Exit(1)

# Compiler Flags
dbg = ['-g']
opt = ['-O2']

if mode == 'debug':
	env.Append(CCFLAGS = dbg)
else:
	env.Append(CCFLAGS = opt)

## TARGETS
BuildDir('obj', 'src', duplicate=0)
Export('env dbg opt')
SConscript('obj/SConscript')
